﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace DesignLife
{
    public partial class NewIntroductionDetail : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection();
        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet ds = new DataSet();

        public DataTable News;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            try
            {

                int qryString = Convert.ToInt32(Request.QueryString["id"]);
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["Design_LifeConnection"].ConnectionString;
                cmd.Connection = conn;
                cmd.CommandText = "select Title,Img1,Contents from News Where NewsID=" + qryString + "";
                cmd.CommandType = CommandType.Text;
                da.SelectCommand = cmd;
                da.Fill(ds, "News");
                News = ds.Tables["News"];
                DataTable tbNews = new DataTable();
                tbNews.Columns.Add("Title", typeof(string));
                tbNews.Columns.Add("Img1", typeof(string));
                tbNews.Columns.Add("Contents", typeof(string));

                if (News != null)
                {
                    for (int i = 0; i < News.Rows.Count; i++)
                    {
                        tbNews.Rows.Add(News.Rows[i]["Title"].ToString(), News.Rows[i]["Img1"].ToString(), News.Rows[i]["Contents"].ToString());
                    }
                }
                dtlNewintrodetail.DataSource = tbNews.DefaultView;
                dtlNewintrodetail.DataBind();
            }
            catch
            {
            }
        }


    }
}